#include "common/excelutils.h"
#include "excelutil/excelutils_p.h"
#include <QStringList>
#include <qfile.h>
ExcelUtils& ExcelUtils::instance()
{
	static ExcelUtils instance;
	return instance;
}
ExcelUtils::~ExcelUtils()
{
}


ExcelUtils::ExcelUtils()
	: d(std::make_unique<ExcelUtilsPrivate>(this))
{
}
bool ExcelUtils::exportXlsx(const QList<QStringList>& list, const QString& path, const QString& sheetName) const
{
	if (list.size() == 0) return false;
	if (path.isEmpty()) return false;
	if (sheetName.isEmpty()) return false;

	return d->exportXlsx(list, path, sheetName);
}

bool ExcelUtils::exportXlsx(const QString& jsonStr, const QString& path, const QString& sheetName) const
{
	if (jsonStr.isEmpty()) return false;
	if (path.isEmpty()) return false;
	if (sheetName.isEmpty()) return false;

	return d->exportXlsx(jsonStr, path, sheetName);
}

QList<QStringList> ExcelUtils::fromXlsx(const QString& path, const QString& sheetName) const
{
	QFile file(path);
	if (!file.exists()) return {};

	return d->fromXlsx(path, sheetName);
}